import json
import os


def read_json(filename, key):
    # 获取当前文件目录
    current_path = os.path.dirname(os.path.realpath(__file__))
    json_path = os.path.join(current_path, f'../config/{filename}')
    # print(json_path)
    with open(json_path, 'r') as f:
        data = json.load(f)
        return data[key]


if __name__ == '__main__':
    scheme = read_json('server.json', 'scheme')
    host = read_json('server.json', 'host')
    port = read_json('server.json', 'port')
    print(scheme, host, port)
